home *** CD-ROM | disk | FTP | other *** search
- extern OSErr
- GetScriptableFinderFilePos(FSSpec *f, Boolean usesystemmode, AESendMode sendmode, Boolean sendToSelf, Rect *r);
-
- extern OSErr
- GetScriptableFinderTrashPos (Boolean usesystemmode, AESendMode sendmode, Boolean sendToSelf, Rect *r);
-
-
- #include <QDOffscreen.h>
-
-
- void InitToolbox()
- {
- InitGraf(&qd.thePort);
- InitFonts();
- FlushEvents(everyEvent, 0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- InitCursor();
- MaxApplZone();
- }
-
- void DoAnimation(void);
-
- //****************************************************************
- void main()
- {
- ProcessSerialNumber fSn;
- FSSpec tSpec;
- OSErr err;
- Rect r;
-
- InitToolbox();
-
- err = FSMakeFSSpec( -2, 0, 0, &tSpec);
-
- DoAnimation();
-
- return;
- }
-
- //****************************************************************
- #define MAX_INC 18
-
- void DoAnimation()
- {
- GrafPtr savP;
- CGrafPort dPort;
- Handle pH;
- Rect trshR, savScrnR, picR, offBufR, wR;
- Rect tmpR, tmpR_0;
- GWorldPtr savScrnGWPtr, picGWPtr, offBufGWPtr;
- PixMapHandle pm;
- GWorldPtr savGW;
- GDHandle savGdH;
- OSErr err;
- short cnt, vInc, del, curAccl;
- long t, startT;
-
- // Save the 'Real' orignial port...
- GetPort( &savP);
-
- // Create a new GrafPort on top of the current port so as to
- // disturb the graphics world as little as possible. This
- // new GrafPort is the default through our copying operations.
-
- OpenCPort( (CGrafPtr)&dPort);
- SetPort( (GrafPtr)&dPort);
-
- GetGWorld( &savGW, &savGdH);
-
- //GetScriptableFinderTrashPos( false, kAEWaitReply, false, &trshR);
- trshR.left = 400;
- trshR.right = trshR.left + 32;
- trshR.top = 640;
- trshR.bottom = trshR.top + 32;
-
-
- // Get the picture
- pH = GetResource( 'PICT', 200);
- picR = (**(PicHandle)pH).picFrame;
-
- // calc drawing sizes
- // TO DO: work on non-main screen correctly...
-
- // savScr, tall column of saved screen
- savScrnR.top = 0;
- savScrnR.left = trshR.left;
- savScrnR.right = savScrnR.left + (picR.right-picR.left);
- savScrnR.bottom = trshR.bottom;
-
- offBufR = picR;
- offBufR.bottom += MAX_INC;
- wR = savScrnR;
- wR.top += 24;
- wR.bottom = wR.top + picR.bottom - picR.top + MAX_INC;
-
- // create offscreen worlds
- err = NewGWorld( &savScrnGWPtr,0,&savScrnR,0,0,useTempMem);
- err = NewGWorld( &picGWPtr,0,&picR,0,0,useTempMem);
- err = NewGWorld( &offBufGWPtr,0,&offBufR,0,0,useTempMem);
-
- // init drawing
- SetGWorld( picGWPtr, 0);
- EraseRect( &picGWPtr->portRect);
- DrawPicture( (PicHandle)pH, &picR);
-
- SetGWorld( offBufGWPtr, 0);
- LockPixels(GetGWorldPixMap(offBufGWPtr));
- EraseRect( &offBufGWPtr->portRect);
-
- // the savScrn rect is always 0,0 -> top,left
- tmpR = savScrnR;
- tmpR.right -= tmpR.left;
- tmpR.left -= tmpR.left;
- tmpR.bottom -= tmpR.top;
- tmpR.top -= tmpR.top;
- SetGWorld( savScrnGWPtr, 0);
- EraseRect( &savScrnGWPtr->portRect);
- LockPixels((pm=GetGWorldPixMap(savScrnGWPtr)));
- CopyBits( (BitMap*)(&(((GrafPtr)&dPort)->portBits)),
- (BitMap*)(*pm),
- &savScrnR, &tmpR,
- patCopy, 0);
-
- #define BASE_INC 1
- // Animation Loop
- startT = TickCount();
- for ( curAccl=1, del=1, cnt=0; cnt<savScrnGWPtr->portRect.bottom/6; cnt++) {
- if ( cnt%5 == 0) curAccl++;
- vInc = BASE_INC + curAccl;
- wR.bottom += vInc;
- wR.top += vInc;
-
- // copy sav to off
- SetGWorld( offBufGWPtr, 0);
- tmpR = wR;
- tmpR.right -= tmpR.left;
- tmpR.left -= tmpR.left;
- tmpR.bottom -= tmpR.top;
- tmpR.top -= tmpR.top;
- tmpR_0 = wR;
- tmpR_0.right -= tmpR_0.left;
- tmpR_0.left -= tmpR_0.left;
- LockPixels((pm=GetGWorldPixMap(offBufGWPtr)));
- CopyBits( (BitMap*)(*(savScrnGWPtr->portPixMap)),
- (BitMap*)(*pm),
- &tmpR_0, &tmpR,
- patCopy, 0);
-
- // copy pic to off, picR is already 0-based
- tmpR = picR;
- tmpR.top += MAX_INC;
- tmpR.bottom += MAX_INC;
- CopyBits( (BitMap*)(*(picGWPtr->portPixMap)),
- (BitMap*)(*pm),
- &picR, &tmpR,
- patOr, 0);
-
- // copy off to dPort
- tmpR = wR;
- tmpR.right -= tmpR.left;
- tmpR.left -= tmpR.left;
- tmpR.bottom -= tmpR.top;
- tmpR.top -= tmpR.top;
- SetGWorld( savGW, savGdH);
- CopyBits( (BitMap*)(*(offBufGWPtr->portPixMap)),
- (BitMap*)(&(((GrafPtr)&dPort)->portBits)),
- &tmpR, &wR,
- patCopy, 0);
-
- if ( t != startT) {
- Delay( del, &t);
- }
- }
-
- // Clean up
- DisposeGWorld( savScrnGWPtr);
- DisposeGWorld( picGWPtr);
- DisposeGWorld( offBufGWPtr);
-
-
- SetPort( savP);
- ClosePort( (GrafPtr)&dPort);
-
- return;
- }
-